<?php

namespace App\Models\Conf;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Notifications\Notifiable;

use App\Models\Conf\Site;
use App\Models\Def\MainGamePlat;

class SiteMainGamePlat extends Model
{
    use Notifiable;

    protected static function boot()
    {
        parent::boot();
        static::addGlobalScope('status', function (Builder $builder) {
            $builder->where('status', '=', 1);
        }
        );
    }

    public $table = 'conf_site_main_game_plats';

    const CREATED_AT = 'created_at';

    const UPDATED_AT = 'updated_at';

    public $fillable = [
        'main_game_plats_id',
        'site_id',
        'status',
        'score',
        'rate',
        'goldpool'
    ];

    protected $casts = [
        'id' => 'integer',
        'main_game_plats_id' => 'integer',
        'site_id' => 'integer',
        'status' => 'boolean',
        'score' => 'numeric',
        'rate' => 'numeric',
        'goldpool' => 'boolean'
    ];

    public static $rules = [];

    public function Site()
    {
        return $this->hasOne(Site::class, 'id', 'site_id');
    }

    public function MainGamePlat()
    {
        return $this->hasOne(MainGamePlat::class, 'id', 'main_game_plats_id');
    }

    public function scopeStatus($query)
    {
        return $query->where('status', 1);
    }
}
